package reflect;

import java.util.Scanner;

/**
 * 反射机制的对象实例化操作
 */
public class ReflectDemo2 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        Person p = new Person();
        System.out.println(p);

//        Class cls = Person.class;
//        Object obj = cls.newInstance();
//        System.out.println(obj);
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个完全限定名:");
        String className = sc.next();
        Class cla = Class.forName(className);
        Object obj = cla.newInstance();
        System.out.println(obj);

    }
}
